<?php

/**
 * @author PeoneEr
 * @package aion personal cabinet v1.0
 * @copyright Aion Factory Inc. 2010-2011
 * @license GNU v3
 * @link Ai-Factory.ru && http://code.google.com/p/aionprivateofficev2
 */
require_once "core/application/models/msettings/msettings.php";
require_once "core/application/classes/errorClass.php";

class settings_Controller extends Settings_Model {

    private static $_instance = NULL;
    public $_lang;
    private $_params = array();

    public static function getInstance() {
        if (is_null(self::$_instance)) {
            $class = __CLASS__;
            self::$_instance = new $class();
        }
        return self::$_instance;
    }

    public function catchGETid() {
        return $_GET['id'];
    }

    public function getInfoForEdit($id) {
        return $this->oneRecord($id);
    }

    public function showSettings() {
        return $this->showAllSettings();
    }

    public function save_settings() {
        /**
         *  сохраняем настройку
         */
        $this->_params = array(
            'value' => $_POST['value'],
            'id' => $_POST['id']
        );
        $this->_lang = $this->getLanguage();
        try {
            $this->saveSettings($this->_params['value'], $this->_params['id']);
            $this->echoSuccess($this->_lang->language['success']);
        } catch (Exception $e) {
            error::getInstance($this->_lang->language['defaultError']);
        }
        unset($this->_params);
    }

}

?>
